<?php
class library_model extends CI_Model
{
	function __construct()
	{
		parent::__construct();
	}
	function getListLibrary($offset,$itemperpage,$projectid)
	{
		$this->db->where('idproject',$projectid);
		$this->db->limit($itemperpage,$offset);
		$this->db->order_by('id','asc');
		$query=$this->db->get('libary');
		return $query->result();
	}
	function getLastLibraryId()
	{
		$this->db->select_max('id');
		$query = $this->db->get('libary');
		return $query->row()->id;
	}
	function addLibrary($library)
	{
		$this->db->insert('libary',$library);
	}
	function delete($libraryId){
		$this->db->where('id',$libraryId);
		$this->db->delete('libary');
	}
	function getLibrary($libraryId)
	{
		$this->db->where('id',$libraryId);
		$query = $this->db->get('libary');
		return $query->row();
	}
	function updateLibrary($library){
		$this->db->where('id',$library['id']);
		$this->db->update('libary',$library);
	}
}